const { ccclass, property } = cc._decorator;

import CScriptMgr from "./cSpriteMgr"
//组件脚本管理
@ccclass
export default class cMountMgr extends cc.Component {
    start(){
        //组件脚本映射
        CScriptMgr.g_mapMounts[this.node.uuid] = this;
        this.extendStart();
    }
    //组件脚本启动扩展
    protected extendStart(){
    }

    //获取逻辑脚本引用
    public getModule(name:string):any{
        return CScriptMgr.getModule(name?name:this.node.uuid);
    }

    //获取逻辑脚本引用
    public myModule():any{
        return this.getModule(null);
    }

    //获取挂载脚本引用
    public getMount(uuid:string):any{
        return CScriptMgr.getMount(uuid?uuid:this.node.uuid);
    }

    //启动逻辑脚本模块
    protected startScript(name:string,object):any{
        let mod = this.getModule(name);
        if(!mod){
            mod = new object();
        }
        mod.changeStart();
        return mod;
    }

    //关闭逻辑脚本模块
    protected closeCript(name:string|null):any{
        let mod = this.getModule(name);
        mod.changeClose();
        return mod;
    }

    //派发事件
    public dispatchs(data:any) {

    }
}
